package com.qhhc.controller;

import com.qhhc.entity.Employee;
import com.qhhc.entity.Role;
import com.qhhc.service.IEmployeeService;
import com.qhhc.service.IRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class EmployeeController {
    @Autowired
    private IEmployeeService employeeService;
    
    @RequestMapping("/getAllEmployees")
    public List<Employee> getAllEmployees() {
        System.out.println("查询所有的员工");
        return employeeService.getAllEmployees();
    }
    
    @RequestMapping("/insertEmployee")
    public String insertEmployee(@RequestBody Employee employee) {
        employeeService.insertEmployee(employee);
        return "insertEmployee";
    }
    @RequestMapping("/deleteEmployeeById")
    public String deleteById(@RequestBody  Long empId) {
        employeeService.deleteEmployee(empId);
        return "deleterole";
    }
    @RequestMapping("/updateEmployeeById")
    public String updateRoleById(@RequestBody Employee employee) {
        employeeService.updateEmployee(employee);
        System.out.println(employee);
        return "updaterole";
    }
    @RequestMapping("/selectEmployeeById")
    public Employee selectRoleById(@RequestParam long employeeId) {
        Employee employeeIdbyId = employeeService.getEmployeeById(employeeId);
        return employeeIdbyId;
    }
}
